﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PES_TurnierManager.Model
{
    class Tournament
    {
        private Dictionary<string, Group> mGroups;

        private bool mGroupPhaseWith2Legs;

        public Tournament()
        {
            mGroups = new Dictionary<string, Group>();
        }

        public Tournament(bool groupsWith2Legs)
        {
            mGroups = new Dictionary<string, Group>();
            mGroupPhaseWith2Legs = groupsWith2Legs;
        }

        public void addGroup(string name, bool with2Legs)
        {
            mGroups.Add(name, new Group(name, with2Legs));
        }

        public void addplayerToGroup(string groupName, string playerName, string teamName)
        {
            mGroups[groupName].addHumanPlayer(playerName, teamName);
        }

        /// <summary>
        /// Return a group
        /// </summary>
        /// <param name="name">name of the group</param>
        /// <returns>null if the group doesnt exist yet</returns>
        public Group getGroup(string name)
        {
            if (!mGroups.ContainsKey(name))
                return null;

            return mGroups[name];
        }

        public List<Match> generateMatchesForGroup(string group)
        {
            return mGroups[group].generateMatches();
        }

    }
}
